//
//  HLLiveUserRankView.m
//  YueYue
//
//  Created by hulu001 on 2024/3/14.
//

#import "HLLiveUserRankView.h"

@implementation HLLiveUserRankView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}



- (void)setupUI
{
    
    self.avatarView = [[UIImageView alloc] init];
    _avatarView.layer.cornerRadius = 22;
    _avatarView.layer.masksToBounds = YES;
    _avatarView.backgroundColor = UIColorRed;
    [self addSubview:_avatarView];
    [_avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(44);
        make.left.mas_equalTo(48);
        make.top.mas_equalTo(12);
        make.bottom.mas_equalTo(-12);
    }];
    
    
    self.nicknameLabel = [[UILabel alloc] init];
    _nicknameLabel.textColor = HLTextColor1;
    _nicknameLabel.text = @"";
    _nicknameLabel.font = UIFontMediumMake(16);
    [self addSubview:_nicknameLabel];
    [_nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_avatarView.mas_right).offset(12);
        make.centerY.equalTo(_avatarView);
        make.right.mas_lessThanOrEqualTo(-134);
    }];
    
    self.rankLabel = [[UILabel alloc] init];
    _rankLabel.font = UIFontMediumMake(16);
    _rankLabel.textColor = HLTextColor3;
    _rankLabel.text = @"1";
    [self addSubview:_rankLabel];
    [_rankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(20);
    }];
    
}


- (void)setModel:(HLLiveUserModel *)model
{
    _model = model;
    
    [_avatarView sd_setImageWithURL:[NSURL URLWithString:model.userAvatar]];
    _nicknameLabel.text = model.userNickName;
    
    
    _rankLabel.textColor = HLTextColor3;
    if ([model.myRank isEqualToString:@"1"]) {
        _rankLabel.textColor = [UIColor qmui_colorWithHexString:@"#FFFF5A7B"];
    } else if ([model.myRank isEqualToString:@"2"]) {
        _rankLabel.textColor = [UIColor qmui_colorWithHexString:@"#FFFF8100"];
    } else if ([model.myRank isEqualToString:@"3"]) {
        _rankLabel.textColor = [UIColor qmui_colorWithHexString:@"#FFFFC511"];
    }
    _rankLabel.text = model.myRank;

    

}


@end
